# coding:utf8

from PyQt5.QtCore import QThread
from PyQt5.QtCore import QObject
import time

class A(QObject):
    def __init__(self):
        super(A, self).__init__()
        self._stop = False
        self.m = 0
        pass
    
    @property
    def stop(self):
        return self._stop
    
    @stop.setter
    def stop(self, enable=False):
        self._stop = enable
        print("set _stop, value is {}".format(self._stop))
    
    def run(self):
        while True:
            print('run , m is {}'.format(self.m))
            self.m += 1
            time.sleep(1)
            
            if self._stop:
                self.m = 0
                print("break, skip run")
                break
            

def main():
    obj = A()
    th = QThread()
    obj.moveToThread(th)
    th.started.connect(obj.run)
    
    
    th.start()
    # time.sleep(5)
    # print("main begin set stop value")
    # obj.stop = True
    # print("main th is quit~")
    # th.quit()
    while True:
        # print("in main while")
        time.sleep(1)
    


if __name__ == '__main__':
    main()
